
#ifndef _MEMBER_AUDIOINPUT_H_
#define _MEMBER_AUDIOINPUT_H_

#include <BBuffer>
#include <BAudioInput>

#ifdef linux
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/soundcard.h>
#endif

#ifdef _WIN32
#include <windows.h>
#include <mmsystem.h>
#undef min
#undef max
#undef far
#undef near
#endif

#define audioinput_member(audio)		((member_BAudioInput*)audio->_ptr)

namespace BWE
{
	class member_BAudioInput
	{
	public:
		member_BAudioInput(BAudioInput* audioInput);
		~member_BAudioInput();

		bool initFormat();

		void emitSignals();

		BAudioInput*		boss;
		Format				format;
		int					fmtlen;
		int					channelCount;
		int					sampleRate;
		bool				dirtyFormat;
		BAudio::State		state;
		BByteArray			buffer;

#ifdef linux
		pthread_mutex_t		mutex;
		int					dsp_fd;
		FILE*				file_fd;
#endif

#ifdef _WIN32
		HWAVEIN				hWaveIn;
		WAVEFORMATEX		wavform;
		WAVEHDR				wavhdr[10];
		CRITICAL_SECTION	bufferSection;
#endif
	};
}

#endif
